<template>
  <div>
    <div>
      <span>测试集中管理store状态</span>
      <div>
        组件主要测试的countStore
        <span>来自countStore的sum值:{{ sum }}和total:{{ total }}</span>
        <span>bigSum(mapGetters):{{ bigSum }}</span>
        <button @click="addSum(3)">sum+3操作(dispatch)</button>
        <button @click="ADDTOTAL(5)">total+5操作(commit)</button>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState, mapActions, mapMutations, mapGetters } from "vuex";
export default {
  computed: {
    ...mapState("count", ["sum", "total"]),
    ...mapGetters("count", { bigSum: "bigSum" }),
  },
  methods: {
    // 演示两种写法:对象写法和数组写法
    ...mapActions("count", { addSum: "addSum" }),
    ...mapMutations("count", ["ADDTOTAL"]),
  },
};
</script>

<style lang="scss" scoped>
</style>